|
|
|
The Complex
class, as it is referred to in C++, would define all of the “methods or tasks
that one would like to perform on that object”. Examples: add, subtract,
multiply, divide, input, output, and even trig functions like sin (complex),
cos (complex), etc., would be defined within the Complex.cc module.
|
|
Note that adding
new data types now localises the changes to a select set of source and
definitions. On the other hand, deciding that a set of classes all need a new
“method” (e.g., additive inverse), would mean that all of the classes needing
this new method now must be modified.
|
|
Object-oriented
design works best when the verbs (procedures) describing a problem are well
understood, but the types of nouns (classes) are not easily categorised. This
is most often the case when the problem size is large, in which case the
number of unique nouns greatly exceeds the number of verbs. For “small”
problems, where there are few types of nouns, procedurally-oriented design
may actually be superior to object-oriented design.
|
|
|